<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>企业碳管理系统 - {% block title %}{% endblock %}</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('index') }}">企业碳管理系统</a>
            <div class="collapse navbar-collapse">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        {% if 'user_id' in session and session.get('role') != 'business_user' %}
                            <a class="nav-link {{ 'active' if request.endpoint == 'user.user_management' else '' }}" href="{{ url_for('user.user_management') }}">用户管理</a>
                        {% endif %}
                    </li>
                    <li class="nav-item">
                        {% if 'user_id' in session and session.get('role') != 'business_user' %}
                            <a class="nav-link {{ 'active' if request.endpoint == 'coefficient.coefficient_list' else '' }}" href="{{ url_for('coefficient.coefficient_list') }}">碳排放系数</a>
                        {% endif %}
                    </li>

                    <li class="nav-item">
                        {% if 'user_id' in session and session.get('role') != 'business_user' %}
                            <a class="nav-link {{ 'active' if request.endpoint == 'coefficient_category.category_list' else '' }}" href="{{ url_for('coefficient_category.category_list') }}">碳排放系数分类</a>
                        {% endif %}
                    </li>
                    <li class="nav-item">
                        <li class="nav-item">
                            {% if 'user_id' in session and session.get('role') != 'business_user' %}
                                <a class="nav-link {{ 'active' if request.endpoint == 'factor.factor_list' else '' }}" href="{{ url_for('factor.factor_list') }}">碳排放因子</a>
                            {% endif %}
                        </li>

                        <li class="nav-item">
                            {% if 'user_id' in session and session.get('role') != 'business_user' %}
                                <a class="nav-link {{ 'active' if request.endpoint == 'factor_category.category_list' else '' }}" href="{{ url_for('factor_category.category_list') }}">碳排放因子分类</a>
                            {% endif %}
                        </li>
                    <li class="nav-item">
                        <li class="nav-item">
                            {% if 'user_id' in session and session.get('role') != 'business_user' %}
                                <a class="nav-link {{ 'active' if request.endpoint == 'model.model_list' else '' }}" href="{{ url_for('model.model_list') }}">模型库管理</a>
                            {% endif %}
                        </li>

                        <li class="nav-item">
                            {% if 'user_id' in session and session.get('role') != 'business_user' %}
                                <a class="nav-link {{ 'active' if request.endpoint == 'model_category.category_list' else '' }}" href="{{ url_for('model_category.category_list') }}">模型库分类</a>
                            {% endif %}
                        </li>
                    <li class="nav-item">
                        <li class="nav-item">
                            {% if 'user_id' in session and session.get('role') != 'business_user' %}
                                <a class="nav-link {{ 'active' if request.endpoint == 'inventory_category.category_list' else '' }}" href="{{ url_for('inventory_category.category_list') }}">碳盘查目录</a>
                            {% endif %}
                        </li>
                    <li class="nav-item">
                        {% if 'user_id' in session %}
                        <a class="nav-link {{ 'active' if request.endpoint == 'inventory.inventory_list' else '' }}" href="{{ url_for('inventory.inventory_list') }}" aria-current="page">碳盘查管理</a>
                        {% endif %}
                    </li>

                    <li class="nav-item">
                        {% if 'user_id' in session %}
                        <a class="nav-link {{ 'active' if request.endpoint == 'report_annual_emission.index' else '' }}" href="{{ url_for('report_annual_emission.index') }}">年度排放报告</a>
                        {% endif %}
                    </li>
                    <li class="nav-item">
                        {% if 'user_id' in session %}
                        <a class="nav-link {{ 'active' if request.endpoint == 'report_fuel_consumption.index' else '' }}" href="{{ url_for('report_fuel_consumption.index') }}">燃料消耗报表</a>
                        {% endif %}
                    </li>
                    <li class="nav-item">
                        {% if 'user_id' in session %}
                        <a class="nav-link {{ 'active' if request.endpoint == 'report_power.index' else '' }}" href="{{ url_for('report_power.index') }}">电力报表</a> 
                        {% endif %}
                    </li>
                    <li class="nav-item">
                        {% if 'user_id' in session %}
                        <a class="nav-link {{ 'active' if request.endpoint == 'report_thermal.index' else '' }}" href="{{ url_for('report_thermal.index') }}">热力报表</a> 
                        {% endif %}
                    </li>
                    <!-- 添加完整报告导航项 -->
                    <li class="nav-item">
                        {% if 'user_id' in session %}
                        <a class="nav-link {{ 'active' if request.endpoint == 'report_complete.index' else '' }}" href="{{ url_for('report_complete.index') }}">完整报告</a>
                        {% endif %}
                    </li>
                    <!-- 添加综合看板导航项 -->
                    <li class="nav-item">
                        {% if 'user_id' in session %}
                        <a class="nav-link {{ 'active' if request.endpoint == 'board_general.index' else '' }}" href="{{ url_for('board_general.index') }}">综合看板</a>
                        {% endif %}
                    </li>

                </ul>
                {% if 'user_id' in session %}
                <div class="d-flex">
                    <div class="dropdown">
                        <button class="btn btn-outline-light dropdown-toggle" type="button" data-bs-toggle="dropdown">
                            {{ session.get('username') }}
                        </button>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><a class="dropdown-item" href="{{ url_for('user.change_password') }}">修改密码</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="{{ url_for('user.logout') }}">登出</a></li>
                        </ul>
                    </div>
                </div>
                {% endif %}
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }}">{{ message }}</div>
                {% endfor %}
            {% endif %}
        {% endwith %}

        {% block content %}{% endblock %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
